package com.sky;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;

/**
 * @author : wushikai
 * <p>
 * date : 2021/8/10
 */
public class LoadSpringFactories {



    /**
     * The location to look for factories.
     * <p>Can be present in multiple JAR files.
     */
    public static final String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories";


    public  static void loadSpringFactories ( ) throws IOException {



        ClassLoader classLoader = ClassLoader.getSystemClassLoader();

        Enumeration<URL> urls = (classLoader != null ?
                classLoader.getResources(FACTORIES_RESOURCE_LOCATION) :
                ClassLoader.getSystemResources(FACTORIES_RESOURCE_LOCATION));

        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            System.out.println(url.toString());

        }


    }



    public static void main(String[] args) throws IOException {

        demo();

    }




    public  static void demo ( ){


        Class<?>[] types = new Class<?>[] { LoadSpringFactories.class, String[].class };
        for (Class<?> type : types) {

            System.out.println(type.getCanonicalName());

        }

    }



}
